#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <string.h>

#include "proto.h"
 
int main(int argc, char *argv[]){
    int sd;
    struct sockaddr_in raddr;
    struct msg_st sbuf;
   
    sd = socket(AF_INET, SOCK_DGRAM, 0 /*IPPROTO_UDP*/);
    if (sd < 0){
        perror("socket()");
        exit(1);
    }
    strcpy(sbuf.name, "dd");
    sbuf.math = htonl(rand()%100);
    
    raddr.sin_family = AF_INET;
    raddr.sin_port = htons(atoi(RCVPORT));
    inet_pton(AF_INET, argv[1], &raddr.sin_addr);

   if(sendto(sd,&sbuf, sizeof(sbuf),0,(void *)&raddr, sizeof(raddr)) < 0 ){
       perror("sendto()");
       exit(1);
   }

    
   
    close();

    exit(0);
}